﻿using Renren.Helpers;
using Renren.Models;

namespace Renren.ViewModels
{
    public class BlogViewModel : ViewModel, IHeaderViewModel
    {
        private BlogModel _blog;
        public BlogModel Blog
        {
            get { return _blog; }
            set
            {
                if (value != _blog)
                {
                    _blog = value;
                    NotifyPropertyChanged("Blog");
                    NotifyPropertyChanged("HeadUrl");
                    NotifyPropertyChanged("Name");
                    NotifyPropertyChanged("UserId");
                    NotifyPropertyChanged("UpdateTime");
                    NotifyPropertyChanged("Title");
                    Content = _blog.Content;
                }
            }
        }

        private string _content;
        public string Content
        {
            get { return _content; }
            set
            {
                if (value != _content)
                {
                    _content = value;
                    NotifyPropertyChanged("Content");
                }
            }
        }
        
        public override long Id
        {
            get { return Blog.Id; }
        }

        public override void Update(Model model)
        {
            throw new System.NotImplementedException();
        }

        public string HeadUrl
        {
            get { return Blog != null ? Blog.HeadUrl : null; }
        }

        public string Name
        {
            get { return Blog != null ? Blog.Name : null; }
        }

        public long UserId
        {
            get { return Blog != null ? Blog.UserId : 0; }
        }

        public string UpdateTime
        {
            get { return Blog != null ?  Blog.UpdateTime.GetFriendlyTime() : null; }
        }

        public string Title
        {
            get { return Blog != null ? Blog.Title : null; }
        }
    }
}
